#ifndef DTBSYSTEM_
#define DTBSYSTEM_
#define EVENT_SEND_DATA 1
#define EVENT_GET_DB 2
#define EVENT_GET_CONFIG 4
#define EVENT_SET_CONFIG 8



class MergeInfo
{
public:
	MergeInfo();
	~MergeInfo();
	void Add(time_t ttTime, uint uiPing);
	void SetReadyCount(uint uiCount);
	bool IsReady();
	time_t GetTime();
	uint GetPing();
	void Merge();
	bool bWrited;
private:
	time_t *TimeArray;
	uint *PingArray;
	bool Ready, IsCreated;
	uint uiReadyCount;
	time_t result_time;
	uint result_ping;

};
class DataBase
{
public:
	DataBase();
	~DataBase();
	void Create(uint id, char* name, uint MachineCount, uint uiWait);
	void AddInfo(uint uiId,time_t ttTime,uint Ping);
	void Update(uint uiTime);
	void SetWaitTime(uint uiTime);
	DTBFile * file;
	uint id;
private:
	char * name;
	MergeInfo miData;
	uint uiWaitTime;
	uint LastTime;


};
class DBManager
{
public:
	DBManager();
	~DBManager();
	void AddDatabase(uint id,char *name);
	void TranslateMessage(char *buf,uint uiSize);
	void Update(uint uiTime);
	void LoadDatabaseListFromFile(char * filename);
	uint uiCount;
	uint GetDBId(uint uiNum);
private:

	uint uiLast;
	DataBase * db;

};
#endif